package com.fly;

import java.util.Arrays;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.util.Assert;

import com.fly.core.config.MybatisConfiguration;
import com.fly.core.config.spring.WebAppInitializer;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * MainRun
 * 
 * @author 00fly
 * @version [版本号, 2019年7月13日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Slf4j
public class MainRun
{
    
    public static void main(String[] args)
    {
        // TODO: ScheduleJob未生效
        ApplicationContext context = new AnnotationConfigApplicationContext(MybatisConfiguration.class, WebAppInitializer.class);
        Assert.notNull(context, "context is null");
        log.info("###### Application Started Success ######");
        Arrays.stream(context.getBeanDefinitionNames()).forEach(log::info);
        ScheduledExecutorService service = new ScheduledThreadPoolExecutor(1);
        service.scheduleAtFixedRate(() -> {
            log.info("---- {}", "hello, 00fly in java!");
        }, 2, 10, TimeUnit.SECONDS);
    }
}
